<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head>
    <th:block th:include="include :: header('修改')"/>
    <th:block th:include="include :: select2-css"/>
</head>
<body>
<div class="main-content">
    <form id="form-change-edit" class="form-horizontal" AUTOCOMPLETE="OFF">
        <input name="id" id="id" type="hidden" th:value="${emp.id}"/>
        <h4 class="form-header h4">基本信息</h4>
        <div class="row">
            <div class="col-sm-6">
                <div class="form-group">
                    <label class="col-sm-4 control-label">工号：</label>
                    <div class="col-sm-8">
                        <input th:value="${emp.badge}" class="form-control" readonly="readonly" type="text"/>
                    </div>
                </div>
            </div>
            <div class="col-sm-6">
                <div class="form-group">
                    <label class="col-sm-4 control-label">姓名：</label>
                    <div class="col-sm-8">
                        <input th:value="${emp.name}" class="form-control" readonly="readonly" type="text"/>
                    </div>
                </div>
            </div>
        </div>
        <div class="row">
            <div class="col-sm-6">
                <div class="form-group">
                    <label class="col-sm-4 control-label">合同签约单位：</label>
                    <div class="col-sm-8">
                        <input th:value="${emp.ContractTitle}" class="form-control" readonly="readonly" type="text"/>
                    </div>
                </div>
            </div>
            <div class="col-sm-6">
                <div class="form-group">
                    <label class="col-sm-4 control-label">合同类型：</label>
                    <div class="col-sm-8">
                        <input th:value="${emp.ConTypeTitle}" class="form-control" readonly="readonly" type="text"/>
                    </div>
                </div>
            </div>
        </div>
        <div class="row">
            <div class="col-sm-6">
                <div class="form-group">
                    <label class="col-sm-4 control-label">合同属性：</label>
                    <div class="col-sm-8">
                        <input th:value="${emp.ConPropertyTitle}" class="form-control" readonly="readonly" type="text"/>
                    </div>
                </div>
            </div>
            <div class="col-sm-6">
                <div class="form-group">
                    <label class="col-sm-4 control-label">合同(年)：</label>
                    <div class="col-sm-8">
                        <input th:value="${emp.ConTerm}" class="form-control" readonly="readonly" type="text"/>
                    </div>
                </div>
            </div>
        </div>
        <div class="row">
            <div class="col-sm-6">
                <div class="form-group">
                    <label class="col-sm-4 control-label">合同属性：</label>
                    <div class="col-sm-8">
                        <input th:value="${emp.ConPropertyTitle}" class="form-control" readonly="readonly" type="text"/>
                    </div>
                </div>
            </div>
            <div class="col-sm-6">
                <div class="form-group">
                    <label class="col-sm-4 control-label">合同结束日期：</label>
                    <div class="col-sm-8">
                        <input th:value="${emp.ConEndDate}" class="form-control" readonly="readonly" type="text"/>
                    </div>
                </div>
            </div>
        </div>
        <div class="row">
            <div class="col-sm-6">
                <div class="form-group">
                    <label class="col-sm-4 control-label">新合同次数：</label>
                    <div class="col-sm-8">
                        <input th:value="${emp.NewConCount}" class="form-control" readonly="readonly" type="text"/>
                    </div>
                </div>
            </div>
        </div>
        <h4 class="form-header h4">修改信息</h4>
        <div class="row">
            <div class="col-sm-6">
                <div class="form-group">
                    <label class="col-sm-4 control-label"><span style="color: red; ">*</span>新合同签约单位：</label>
                    <div class="col-sm-8">
                        <select id="NewContract" name="NewContract" class="form-control"
                                required>
                            <option value="">请选择</option>
                            <option th:each="company:${companys}"
                                    th:value="${company.id}" th:text="${company.title}"
                                    th:selected="${emp.NewContract==company.id}"></option>
                        </select>
                    </div>
                </div>
            </div>
            <div class="col-sm-6">
                <div class="form-group">
                    <label class="col-sm-4 control-label"><span style="color: red; ">*</span>新合同类型：</label>
                    <div class="col-sm-8">
                        <select name="NewContype" id="NewContype" class="form-control m-b"
                                th:with="type=${@dict.getType('eCD_ConType')}">
                            <option value="">请选择</option>
                            <option th:each="dict : ${type}" th:text="${dict.dictLabel}"
                                    th:selected="${emp.NewContype+'' == dict.dictValue}"
                                    th:value="${dict.dictValue}"></option>
                        </select>
                    </div>
                </div>
            </div>
        </div>
        <div class="row">
            <div class="col-sm-6">
                <div class="form-group">
                    <label class="col-sm-4 control-label"><span style="color: red; ">*</span>新合同属性：</label>
                    <div class="col-sm-8">
                        <select name="NewConProperty" id="NewConProperty" class="form-control m-b"
                                th:with="type=${@dict.getType('eCD_ConProperty')}">
                            <option value="">请选择</option>
                            <option th:each="dict : ${type}" th:text="${dict.dictLabel}"
                                    th:selected="${emp.NewConProperty+'' == dict.dictValue}"
                                    th:value="${dict.dictValue}"></option>
                        </select>
                    </div>
                </div>
            </div>
            <div class="col-sm-6">
                <div class="form-group">
                    <label class="col-sm-4 control-label"><span style="color: red; ">*</span>新合同开始日期：</label>
                    <div class="col-sm-8">
                        <input name="NewConBeginDate" id="NewConBeginDate" th:value="${emp.NewConBeginDate}"
                               class="form-control laydate-demo-1" type="text" required/>
                    </div>
                </div>
            </div>
        </div>
        <div class="row">
            <div class="col-sm-6">
                <div class="form-group">
                    <label class="col-sm-4 control-label">新合同期(年)：</label>
                    <div class="col-sm-8">
                        <input name="NewConTerm" id="NewConTerm" th:value="${emp.NewConTerm}"
                               class="form-control" type="text"
                               required/>
                    </div>
                </div>
            </div>
            <div class="col-sm-6">
                <div class="form-group">
                    <label class="col-sm-4 control-label">新合同结束日期：</label>
                    <div class="col-sm-8">
                        <input name="NewConEndDate" id="NewConEndDate" th:value="${emp.NewConEndDate}"
                               class="form-control laydate-demo-3"
                               type="text" required/>
                    </div>
                </div>
            </div>
        </div>
        <div class="row">
            <div class="col-sm-6">
                <div class="form-group">
                    <label class="col-sm-4 control-label"><span style="color: red; ">*</span>生效日期：</label>
                    <div class="col-sm-8">
                        <input name="EffectDate" id="EffectDate" th:value="${emp.EffectDate}"
                               class="form-control laydate-demo-2"
                               type="text" required/>
                    </div>
                </div>
            </div>
            <div class="col-sm-6">
                <div class="form-group">
                    <label class="col-sm-4 control-label">备注：</label>
                    <div class="col-sm-8">
                        <input name="remark" id="remark" th:value="${emp.remark}" class="form-control"
                               type="text" />
                    </div>
                </div>
            </div>
        </div>

    </form>
</div>


<th:block th:include="include :: footer"/>
<th:block th:include="include :: select2-js"/>
<th:block th:include="include :: datetimepicker-js"/>

<script th:inline="javascript">

    var prefix = ctx + "contractManage/changeContract";

    $(function () {
        layui.use('laydate', function () {
            var laydate = layui.laydate;
            laydate.render({
                elem: '.laydate-demo-1',
                type: 'date'
            });

            laydate.render({
                elem: '.laydate-demo-2',
                type: 'date'
            });

            laydate.render({
                elem: '.laydate-demo-3',
                type: 'date'
            });
        });
    });

    function submitHandler() {
        if ($.validate.form()) {
            var data = $("#form-change-edit").serializeArray();
            var id = $("#id").val();
            var NewContract = $("#NewContract").val();
            var NewContype = $("#NewContype").val();
            var NewConProperty = $("#NewConProperty").val();
            var NewConBeginDate = $("#NewConBeginDate").val();
            var NewConTerm = $("#NewConTerm").val();
            var NewConEndDate = $("#NewConEndDate").val();
            var EffectDate = $("#EffectDate").val();
            var remark = $("#remark").val();
            if(NewContract == "" || NewContract == null){
                $.modal.alertWarning("请选择新合同签约单位!");
                return;
            } else if (NewContype == "" || NewContype == null) {
                $.modal.alertWarning("请选择新合同类型!");
                return;
            } else if (NewConProperty == "" || NewConProperty == null) {
                $.modal.alertWarning("请选择新合同属性!");
                return;
            }

            data.push({"name": "id", "value": id});
            data.push({"name": "NewContract", "value": NewContract});
            data.push({"name": "NewContype", "value": NewContype});
            data.push({"name": "NewConProperty", "value": NewConProperty});
            data.push({"name": "NewConBeginDate", "value": NewConBeginDate});
            data.push({"name": "NewConTerm", "value": NewConTerm});
            data.push({"name": "NewConEndDate", "value": NewConEndDate});
            data.push({"name": "EffectDate", "value": EffectDate});
            data.push({"name": "remark", "value": remark});
            $.operate.save(prefix + "/edit", data);
        }
    }

    function getConEndDate() {
        var ConBeginDate = $("#ConBeginDate").val();
        var ConTerm = $("#ConTerm").val();
        var date = new Date(ConBeginDate);
        $("#ConEndDate").val(date.getFullYear() + parseInt(ConTerm) + '-' + (date.getMonth() + 1) + '-' + date.getDate());
    }


</script>
</body>
</html>
